/*
-----------------------------------------------------------------------------
This source file is part of Labor3D
(Labor 3D Graphics Engine)

Copyright (c) 2009-2020 Rock Mao
* creator : Rock Mao
* created : 2011-2-11   11:37
* filename: LaborModelLaoder.h
-----------------------------------------------------------------------------
*/

#ifndef __LABORMODELLAODER_H__
#define __LABORMODELLAODER_H__
#include "../LaborCoreDef.h"
#include "LaborModelDecl.h"
#include "../Common/LaborResourceManager.h"
#include "../Renderer/LaborTextureManager.h"
NAMESPACE_LABOR3D_BEGIN


class  LABORCORE_API  CLModelLoader : public xResPathManager
{
protected:
	CLModelLoader();
	virtual ~CLModelLoader();
public:  
	HBaseModel              loadModel(const wchar_t* _modelFile , bool bLoadEmbMesh , bool bLoadImmg);
	//HBaseMesh               loadMesh(const wchar_t*  _meshName  , const wchar_t* _ownModelName = NULL , bool bLoadImm = true);
	const wchar_t*          getModelExtName();
	LaborBaseTextureMgr*    getTextureMgr();
	void                    setThis(CLBaseModelMgr* pThis){ m_pThis = pThis ; }

public:
	void                KillObject();
	static              CLBaseModelMgr* createInstance(LaborBaseTextureMgr* pTexMgr , const wchar_t* _name);
public:			       
	const wchar_t*     ext();
protected:
	unsigned int       _getResSize(CLBaseModel* pRes);
	virtual bool       _isResLoaded(CLBaseModel* pRes);
	virtual bool       _postLoadResource  (const std::ds_wstring& strResName , CLBaseModel* & pRes , int& ResSize, unsigned int arg) { return true ; }
	virtual bool       _preLoadResource  (const std::ds_wstring& strResName , CLBaseModel* & pRes , int& ResSize, unsigned int arg)  { return true ; }
	virtual bool       _loadResource  (const std::ds_wstring& strResName , CLBaseModel* & pRes , int& ResSize, unsigned int arg);
	virtual bool       _unloadResource(const std::ds_wstring& strResName , CLBaseModel* & pRes , unsigned int& TotalResSize);
	virtual void       _deleteResource(const std::ds_wstring& strResName , CLBaseModel* pRes);
protected:
	bool         _loadFromFile(const std::ds_wstring& strResDir , const std::ds_wstring& strResName , CLBaseModel* pRes, unsigned int arg);
	bool         _loadFromPackage(xResPkgPathItem& item , const std::ds_wstring& _name , CLBaseModel* pRes, unsigned int arg);
protected:
	LaborBaseTextureMgr*  m_pTexMgr;
	//CLBaseMeshMgr           m_MeshMgr;
	std::ds_wstring               m_ext;
	CLBaseModelMgr*         m_pThis;
};
NAMESPACE_LABOR3D_END

#endif // __LABORBASEMESH_H__
